Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit 'unsubsribe' event when client has clean=true on disconnect #145 #171

Merged
merged 2 commits into from
Nov 16, 2017

Conversation

cordovapolymer
Copy link
Contributor

@mcollina , i've implemented #145, please review if it's ok to merge.

@@ -68,7 +68,7 @@ function completeUnsubscribe (err) {
return client.emit('error', err)
}

if (!packet.close && packet.unsubscriptions.length > 0) {
if (client.clean === true && packet.unsubscriptions.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check for packet.close  must stay. See https://github.com/mcollina/aedes/blob/275bda32461ea8053c8610b8a3e5b6f0f838f1b6/lib/client.js#L214.
Basically if packet.close === true && client.clean === false we should not emit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcollina , thank you for a clarification, please see the new commit

@@ -123,7 +123,7 @@ test('emit unsubscribe event', function (t) {
t.plan(6)

var broker = aedes()
var s = connect(setup(broker), { clientId: 'abcde' })
var s = connect(setup(broker), { clean: true, clientId: 'abcde' })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add another test that fails if the event is emitted when clean is false and the connection ends abruptly?

Copy link
Collaborator

@mcollina mcollina Nov 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget about it, it's already added.

@mcollina
Copy link
Collaborator

LGTM

@mcollina mcollina merged commit 3e7941b into moscajs:master Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants